/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Thai Dac Vinh
 */
@Entity
@Table(name = "ACCOUNT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Account.findAll", query = "SELECT a FROM Account a"),
    @NamedQuery(name = "Account.findByAid", query = "SELECT a FROM Account a WHERE a.aid = :aid"),
    @NamedQuery(name = "Account.findByOwnername", query = "SELECT a FROM Account a WHERE a.ownername = :ownername"),
    @NamedQuery(name = "Account.findByCreateddate", query = "SELECT a FROM Account a WHERE a.createddate = :createddate"),
    @NamedQuery(name = "Account.findByBalance", query = "SELECT a FROM Account a WHERE a.balance = :balance")})
public class Account implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 5)
    @Column(name = "AID")
    private String aid;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "OWNERNAME")
    private String ownername;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CREATEDDATE")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createddate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BALANCE")
    private float balance;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "senderAccount")
    private Collection<Moneytransferlog> moneytransferlogCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "receiverAccount")
    private Collection<Moneytransferlog> moneytransferlogCollection1;

    public Account() {
    }

    public Account(String aid) {
        this.aid = aid;
    }

    public Account(String aid, String ownername, Date createddate, float balance) {
        this.aid = aid;
        this.ownername = ownername;
        this.createddate = createddate;
        this.balance = balance;
    }

    public String getAid() {
        return aid;
    }

    public void setAid(String aid) {
        this.aid = aid;
    }

    public String getOwnername() {
        return ownername;
    }

    public void setOwnername(String ownername) {
        this.ownername = ownername;
    }

    public Date getCreateddate() {
        return createddate;
    }

    public void setCreateddate(Date createddate) {
        this.createddate = createddate;
    }

    public float getBalance() {
        return balance;
    }

    public void setBalance(float balance) {
        this.balance = balance;
    }

    @XmlTransient
    public Collection<Moneytransferlog> getMoneytransferlogCollection() {
        return moneytransferlogCollection;
    }

    public void setMoneytransferlogCollection(Collection<Moneytransferlog> moneytransferlogCollection) {
        this.moneytransferlogCollection = moneytransferlogCollection;
    }

    @XmlTransient
    public Collection<Moneytransferlog> getMoneytransferlogCollection1() {
        return moneytransferlogCollection1;
    }

    public void setMoneytransferlogCollection1(Collection<Moneytransferlog> moneytransferlogCollection1) {
        this.moneytransferlogCollection1 = moneytransferlogCollection1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (aid != null ? aid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Account)) {
            return false;
        }
        Account other = (Account) object;
        if ((this.aid == null && other.aid != null) || (this.aid != null && !this.aid.equals(other.aid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Account[ aid=" + aid + " ]";
    }
    
}
